<template>
    <div>
        <h1>订单管理</h1>
         <search :options="options" @search="searchs"></search>
         <Tables :cols="cols" :data="this.list" :pageNum="pageNum" :pageSize="pageSize" :total="total"  @handleSizeChange="handleSizeChange"
            @handleCurrentChange="handleCurrentChange">
              <template v-slot:action="{row}">
                <el-button type="primary" size="mini" @click="lookup(row.orderNo)">查看</el-button>
            </template>
         </Tables>
    </div>
</template>

<script>
import Tables from "../../common/table.vue";
import search from "../../common/search.vue";
import { orderList,orderSearch } from "../../../http/index.js";
export default {
  components: { Tables, search },
  data() {
    return {
        options: [
        {
          value: "id",
          label: "按订单号进行搜索"
        },
      ],
      pageNum: 1,
      pageSize: 10,
      total:0,
      list: [],
      cols: [
        {
          label: "订单号",
          name: "orderNo"
        },
        {
          label: "收件人",
          name: "receiverName"
        },
        {
          label: "订单状态",
          name: "statusDesc"
        },
        {
          label: "订单总价",
          name: "payment"
        },
        {
          label: "创建时间",
          name: "createTime"
        },
        {
          label: "操作",
          name: "attress",
          slot: "action"
        }
      ]
    };
  },
  mounted() {
    this.getOrderList();
  },
  methods: {
    async getOrderList() {
      let res = await orderList({
        pageSize: this.pageSize,
        pageNum: this.pageNum
      });
      console.log(res);
      this.list=res.data.data.list
      this.total = res.data.data.total;
    },
    lookup(orderNo){
        this.$router.push({path:'/orderLook',query:{orderNo:orderNo}})
        console.log(orderNo);
    },
    async searchs(id,keyword){
       let res = await orderSearch({orderNo:keyword})
       console.log(res);
        this.list=res.data.data.list
    },
    handleSizeChange(val) {
      this.pageSize = val;
      console.log(this.pageSize);
      orderList({ pageSize: this.pageSize }).then(res => {
        console.log("111", res);
        this.list = res.data.data.list;
      });
    },
    handleCurrentChange(val) {
      this.pageNum = val;
      console.log(this.pageNum);
      orderList({ pageNum: this.pageNum }).then(res => {
        console.log("222", res);
        this.list = res.data.data.list;
      });
    },
  }
};
</script>

<style lang="scss" scoped>
</style>
